#include "OpenGLVisualizer.h"
#include <GL/gl.h>
#include <GL/glut.h>

#define VLARE_GL_LIS_OFFSET 320

void OpenGLVisualizer::Init(VlareHashMap properties)
{
}
void OpenGLVisualizer::AcquireResources()
{
}
void OpenGLVisualizer::FreeResources()
{
}
void OpenGLVisualizer::Free()
{
}
void OpenGLVisualizer::RegisterElement(Element* pElem)
{
	//glNewList(nextListIndex++, GL_);
}

void OpenGLVisualizer::UnregisterElement(Element* pElem)
{
}

void OpenGLVisualizer::PreDraw()
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	//gluOrtho2D(0, glutGet(GLUT_WINDOW_WIDTH), 0, glutGet(GLUT_WINDOW_HEIGHT));
	gluOrtho2D(0, 1, 1, 0);
}

void OpenGLVisualizer::DrawElement(const Element *const pElem, CostumeImage *const pImg)
{
	Vloat x = (*pElem)[VEM_POSITIONX];
	Vloat y = (*pElem)[VEM_POSITIONY];
	Vloat w = (*pElem)[VEM_WIDTH];
	Vloat h = (*pElem)[VEM_HEIGHT];
	//printf("%f\n",x.val.dVal);
	glBegin(GL_QUADS);
		glVertex3f(x,y,0.0);
		glVertex3f(x+w,y,0.0);
		glVertex3f(x+w,y+h,0.0);
		glVertex3f(x,y+h,0.0);
	glEnd();
}
void OpenGLVisualizer::PostDraw()
{
}
